package com.azt.provider.impl;

import com.azt.api.pojo.UserVisit;
import com.azt.api.service.UserVisitService;
import com.azt.provider.mapper.UserVisitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserVisitServiceImpl implements UserVisitService {

    @Autowired
    private UserVisitMapper userVisitMapper;

    @Override
    public void recordVisit(Integer userId, Integer tableId, String type) {
        UserVisit userVisit = new UserVisit();
        userVisit.setUserId(userId);
        userVisit.setTableId(tableId);
        userVisit.setType(type);
        userVisitMapper.insertSelective(userVisit);
    }

    @Override
    public int getVisitCount(Integer userId, Integer tableId, String type) {
        UserVisit userVisit = new UserVisit();
        userVisit.setUserId(userId);
        userVisit.setTableId(tableId);
        userVisit.setType(type);
        return userVisitMapper.selectCount(userVisit);
    }

}
